const baseUrl = ' http://www.91sokertest.com/api'
const apiUrl = 'http://shop.jufengnr.net/gateway-feature/api'   
const apiUrlJF = 'http://shop.jufengnr.net'
var jf = ''   
   
const request = (urlType= '', url = '', type = '', date = {}, header = {
}) => {
	// console.log(url)
	// console.log(urlType == 'old'? apiUrl : apiUrlJF + url)
	jf = urlType == 'old'? apiUrl : apiUrlJF
	var that = this
    return new Promise((resolve, reject) => {
        uni.request({
            method: type,
            url: baseUrl + url,
            data: date,
            header: {
				'User-Token': uni.getStorageSync('userInfo').User_Token
			},
            dataType: 'json'         
        }).then((response) => {
			console.log(response)
			let [error, res] = response;
			resolve(res.data);
			// if(response[1].data.msg == '无权限用户'){
			// 	uni.showToast({
			// 	    title: '请先登录',
			// 		icon: 'none',
			// 	    duration: 2000
			// 	});
			// 	uni.navigateTo({
			// 		url: '/pages/clues/index.vue'
			// 	})
			// 	return
			// }
			// console.log(uni.getStorageSync('x-auth-app-token'))
        }).catch(error => {
            let [err, res] = error;
            reject(err)
			console.log(error[1].data)
			uni.showToast({
			    title: error,
				icon: 'none',
			    duration: 2000
			});
        })
    });
	
}
export default request